/*
 * @lc app=leetcode.cn id=447 lang=javascript
 *
 * [447] 回旋镖的数量
 */

// @lc code=start
/**
 * @param {number[][]} points
 * @return {number}
 */
var numberOfBoomerangs = function (points) {
    let dis = function (p1, p2) {
        return (points[p1][0] - points[p2][0]) ** 2 + (points[p1][1] - points[p2][1]) ** 2
    }
    let res=0
    let len = points.length
    for (let i = 0; i < len; i++) {
        let map = new Map()
        for (j = 0; j < len; j++) {
            if(j!=i)
            {let d=dis(i,j)
            if(!map.get(d)){
                map.set(d,1)
            }else{
                map.set(d,map.get(d)+1)
            }}
        }
        map.forEach((v,k)=>{
            res+=v*(v-1)
        })
    }
    return res
};
// @lc code=end

